<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	public function _initDb(){
		$dbOption = $this->getOption("resources");
		$dbOption = $dbOption["db"];
	
		//setup database
		$db = Zend_Db::factory($dbOption["adapter"],$dbOption["params"]);
	
		$db->setFetchMode(Zend_Db::FETCH_ASSOC);
		$db->query("SET NAMES 'utf8'");
		$db->query("SET CHARACTER SET 'utf8'");
	
		Zend_Registry::set("connectDb", $db);
		Zend_Db_Table::setDefaultAdapter($db);
		return $db;
	}
	
	public function _initSession(){
		Zend_Session::start();
	}
	
	/* protected function _initNavigation()
	{
		$db = Zend_Db_Table::getDefaultAdapter();
		$select = $db->select()
		->from('categories')
		->order('cat_id ASC');
		$result = $db->fetchAll($select);
	
		$re = new Private_System_Recursive($result);
		$pages = $re->buildRecursive(0);
	
		$resource = new Zend_Application_Resource_Navigation(array(
				'pages' => $pages,
		));
		$resource->setBootstrap($this);
		return $resource->init();
	} */
	
	/* protected function _initRouters(){
		$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routers.ini','setup-router');
		$objRouter = new Zend_Controller_Router_Rewrite();
		//new Zend_Controller_Router_Route_Regex()
		$router = $objRouter->addConfig($config,'routers');
		
		$front = Zend_Controller_Front::getInstance();
		$front->setRouter($router);
	} */
	
	protected function _initLoadRouter(){
	
		$config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/routers.ini','setup-router');
		$objRouter = new Zend_Controller_Router_Rewrite();
		//new Zend_Controller_Router_Route_Regex()
		$router = $objRouter->addConfig($config,'routers');
	
		$front = Zend_Controller_Front::getInstance();
		$front->setRouter($router);
	}
	
}

